﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProjectSchedule.Entity
{
    public class CTSectionPlan
    {
        public CTSectionPlan() { }

        public CTSectionPlan(DateTime LargeMergeTime,CTSectionTime SectionTime) 
        {
            if (LargeMergeTime == null) return;
            this.ShipName = SectionTime.ShipName;
            this.SectionName = SectionTime.SectionName;
            this.LargeMergeStop = LargeMergeTime.AddDays(SectionTime.LargeMerge-1);
            this.LargeMergeStart = LargeMergeTime;

            int offsetDays = SectionTime.MediumMergeBInterval;
            this.MediumMergeBStop = SectionTime.MediumMergeB == 0 ? (DateTime?)null : LargeMergeTime.AddDays(-offsetDays - 1);
            offsetDays += SectionTime.MediumMergeB;
            this.MediumMergeBStart = SectionTime.MediumMergeB == 0 ? (DateTime?)null : LargeMergeTime.AddDays(-offsetDays);

            offsetDays += SectionTime.MediumPaintingInterval;
            this.MediumPaintingStop = SectionTime.MediumPainting == 0 ? (DateTime?)null : LargeMergeTime.AddDays(-offsetDays - 1);
            offsetDays += SectionTime.MediumPainting;
            this.MediumPaintingStart = SectionTime.MediumPainting == 0 ? (DateTime?)null : LargeMergeTime.AddDays(-offsetDays);

            offsetDays += SectionTime.MediumMergeAInterval;
            this.MediumMergeAStop = SectionTime.MediumMergeA == 0 ? (DateTime?)null : LargeMergeTime.AddDays(-offsetDays - 1);
            offsetDays += SectionTime.MediumMergeA;
            this.MediumMergeAStart = SectionTime.MediumMergeA == 0 ? (DateTime?)null : LargeMergeTime.AddDays(-offsetDays);

            offsetDays += SectionTime.MediumGroupInterval;
            this.MediumGroupStop = SectionTime.MediumGroup == 0 ? (DateTime?)null : LargeMergeTime.AddDays(-offsetDays - 1);
            offsetDays += SectionTime.MediumGroup;
            this.MediumGroupStart = SectionTime.MediumGroup == 0 ? (DateTime?)null : LargeMergeTime.AddDays(-offsetDays);

            offsetDays += SectionTime.SmallGroupInterval;
            this.SmallGroupStop = SectionTime.SmallGroup == 0 ? (DateTime?)null : LargeMergeTime.AddDays(-offsetDays - 1);
            offsetDays += SectionTime.SmallGroup;
            this.SmallGroupStart = SectionTime.SmallGroup == 0 ? (DateTime?)null : LargeMergeTime.AddDays(-offsetDays);

            offsetDays += SectionTime.CuttingInterval;
            this.CuttingStop = SectionTime.Cutting == 0 ? (DateTime?)null : LargeMergeTime.AddDays(-offsetDays - 1);
            offsetDays += SectionTime.Cutting;
            this.CuttingStart = SectionTime.Cutting == 0 ? (DateTime?)null : LargeMergeTime.AddDays(-offsetDays);

            offsetDays += SectionTime.PretreatInterval;
            this.PretreatStop = SectionTime.Pretreat == 0 ? (DateTime?)null : LargeMergeTime.AddDays(-offsetDays - 1);
            offsetDays += SectionTime.Pretreat;
            this.PretreatStart = SectionTime.Pretreat == 0 ? (DateTime?)null : LargeMergeTime.AddDays(-offsetDays);

            this.PlanSectionTime = SectionTime;
        }
        public string ShipName { get; set; }
        public string SectionName { get; set; }
        public double Weight { get; set; }

        /// <summary>
        /// 预制工期
        /// </summary>
        public DateTime? PretreatStart { get; set; }
        public DateTime? PretreatStop { get; set; }

        /// <summary>
        /// 下料工期
        /// </summary>
        public DateTime? CuttingStart { get; set; }
        public DateTime? CuttingStop { get; set; }

        /// <summary>
        /// 小组工期
        /// </summary>
        public DateTime? SmallGroupStart { get; set; }
        public DateTime? SmallGroupStop { get; set; }

        /// <summary>
        /// 中组工期
        /// </summary>
        public DateTime? MediumGroupStart { get; set; }
        public DateTime? MediumGroupStop { get; set; }

        /// <summary>
        /// 中合A工期
        /// </summary>
        public DateTime? MediumMergeAStart { get; set; }
        public DateTime? MediumMergeAStop { get; set; }

        /// <summary>
        /// 中涂工期
        /// </summary>
        public DateTime? MediumPaintingStart { get; set; }
        public DateTime? MediumPaintingStop { get; set; }

        /// <summary>
        /// 中合B工期
        /// </summary>
        public DateTime? MediumMergeBStart { get; set; }
        public DateTime? MediumMergeBStop { get; set; }

        /// <summary>
        /// 大合工期
        /// </summary>
        public DateTime? LargeMergeStart { get; set; }
        public DateTime? LargeMergeStop { get; set; }

        /// <summary>
        /// 试航工期
        /// </summary>
        //public DateTime TrialTripStart { get; set; }
        //public DateTime TrialTripStop { get; set; }

        public CTSectionTime PlanSectionTime { get; set; }

        public CTProcessUnit Units { get; set; }
    }
}
